package com.ruoyi.lm.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.lm.domain.LmUser;
import com.ruoyi.lm.service.ILmUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户Controller
 * 
 * @author ruoyi
 * @date 2020-09-02
 */
@Controller
@RequestMapping("/phone/lm/user")
public class LmUserControllerPhone extends BaseController
{
    @Autowired
    private ILmUserService lmUserService;

    /**
     * 查询用户信息
     */
    @PostMapping("/listByUserId")
    @ResponseBody
    public AjaxResult listByUserId(String userId)
    {
        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",lmUserService.selectLmUserById(userId));
    }

    /**
     * 查询好友列表
     */
    @PostMapping("/listInvention")
    @ResponseBody
    public TableDataInfo listInvention(String id)
    {
        LmUser lmUser = new LmUser();
        lmUser.setUserPId(id);
        List<LmUser> list = lmUserService.selectLmUserList(lmUser);
        return getDataTable(list);
    }

    /**
     * 查询用户信息
     */
    @PostMapping("/listSignName")
    @ResponseBody
    public AjaxResult listSignName(String userId)
    {
        LmUser lmUser =new LmUser();
        return new AjaxResult(AjaxResult.Type.SUCCESS,"200",lmUserService.selectLmUserById(userId));
    }

    /**
     * 修改保存用户
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody LmUser lmUser)
    {
        return toAjax(lmUserService.updateLmUser(lmUser));
    }

}
